home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 051-075 / disk_056 / getvolume / getvolume.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  1KB  |  42 lines

  1. /* GetVolume.c     -- Written  02/13/87 by Chuck McManis feel free to use it
  2.  * 
  3.  * This simple Program can be used to get the Volume name for a given file. 
  4.  * Works on any device, even the RAM: device.
  5.  *
  6.  * Note: The BADDR macro is in the dos.h file
  7.  */
  8.  
  9. #include <exec/types.h>
  10. #include <libraries/dos.h>
  11. #include <libraries/dosextens.h>
  12. #include <stdio.h>
  13.  
  14. void main()
  15.  
  16. {
  17.   char    VolumeName[40], FileName[80], *MyVolume;
  18.   struct FileLock    *MyLock;
  19.  
  20.  
  21.   printf("Enter a file name :");
  22.   gets(FileName);
  23.  
  24.   /* Simultaneous get a lock and convert BPTR to a C pointer */
  25.   MyLock = (struct FileLock *)BADDR(Lock(FileName,ACCESS_READ));
  26.   if (MyLock == NULL) {
  27.     printf("File could not be found!\n");
  28.     exit(20); /* Die appropriately on failure */
  29.     }
  30.   /* This next statement chases the BCPL pointers thru a FileLock and    *
  31.    * DeviceList structures                         */
  32.   MyVolume = (char *)
  33.        BADDR(((struct DeviceList *)BADDR(MyLock->fl_Volume))->dl_Name);
  34.   /* Lattice V3.10 function to copy a string and Null terminate it */
  35.   stccpy(VolumeName,MyVolume+1,MyVolume[0]+1);
  36.   printf("That file resides on Volume '%s' \n",VolumeName);
  37.   UnLock(((long)MyLock) >> 2);  /* You must UnLock or the GURU visits */
  38.   exit(0);
  39. }
  40.  
  41.  
  42.